package com.linkzd.iot.controller;

import com.linkzd.common.core.controller.BaseController;
import com.linkzd.common.core.domain.AjaxResult;
import com.linkzd.common.core.page.TableDataInfo;
import com.linkzd.iot.domain.RoomInfo;
import com.linkzd.iot.service.IRoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

    @RestController
    @RequestMapping("/room/roomInfo")
    public class RoomInfoController extends BaseController {

        @Qualifier("roomInfoServiceImpl")
        @Autowired
        private IRoomInfoService IRoomInfoService;

        @PreAuthorize("@ss.hasPermi('room:roomInfo:list')")
        @GetMapping("/list")
        public TableDataInfo list(RoomInfo roomInfo)
        {
            startPage();
            List<RoomInfo> roList = IRoomInfoService.selectRoomInfoList(roomInfo);
            return getDataTable(roList);
        }

        @PreAuthorize("@ss.hasPermi('room:roomInfo:add')")
        @PostMapping()
        public AjaxResult add(@RequestBody RoomInfo roomInfo)
        {
            return toAjax(IRoomInfoService.insertRoomInfo(roomInfo));
        }

        @PreAuthorize("@ss.hasPermi('room:roomInfo:edit')")
        @PutMapping
        public AjaxResult edit(@RequestBody  RoomInfo roomInfo)
        {
            return toAjax(IRoomInfoService.updateRoomInfo(roomInfo));
        }

        @PreAuthorize("@ss.hasPermi('room:roomInfo:remove')")
        @DeleteMapping("/{id}")
        public AjaxResult remove(@PathVariable Long id)
        {
            return toAjax(IRoomInfoService.deleteRoomInfoById(id));
        }
    }

